home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.0
/
Video Toaster v4.0.iso
/
arexx
/
modeler
/
mvplot.lwm
< prev
next >
Wrap
Text File
|
1993-12-13
|
7KB
|
305 lines
/* CMD: MathVision Plot
* Plot surface from Seven Seas Software's MathVision in modeler
* for good results, map a MathVision contour plot onto this object
* by Arnie Cachelin © 1993 NewTek, Inc.
*/
arg bas
call addlib "LWModelerARexx.port", 0
signal on error
signal on syntax
if ~show('P',"MathVision") then do
notify(1,"!Can't find MathVision...","Is it running?")
exit
end
ADDRESS "MathVision"
OPTIONS RESULTS
MATHLIB="rexxmathlib.library"
IF POS(MATHLIB , SHOW('L')) = 0 THEN
IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
call notify(1,"!Can't find "MATHLIB)
exit
END
call addlib "rexxsupport.library", 0, -30, 0
sysnam = 'MathVision Plot'
filnam = 'ENV:MVplot.state'
version = 'MVPlot v1.0'
/* Setup state. Read stored one, if any.
*/
Get 'Xmin' ; x1=RESULT
Get Ymin ; y1=RESULT
Get 'Xmax' ; x2=RESULT
Get 'Ymax' ; y2=RESULT
Get 'ContourAnchor' ; z1=RESULT
Get 'ContourTop' ; z2=RESULT
NSX = 20
NSY = 20
flip = 1
tri = 1
typ=2
call req_begin sysnam
id_nsx = req_addcontrol("X Segments", 'n')
id_nsy = req_addcontrol("Y Segments", 'n')
id_tri = req_addcontrol("Triangles", 'b')
id_typ = req_addcontrol("Build: ","CH","Points Polys Curves")
call req_setval id_nsx, nsx, 20
call req_setval id_nsy, nsy, 20
call req_setval id_tri, tri,tri
call req_setval id_typ, typ,typ
if (~req_post()) then do
call req_end
exit
end
NSX = req_getval(id_nsx) % 1
NSY = req_getval(id_nsx) % 1
typ = req_getval(id_typ)
tri = req_getval(id_tri)
call req_end
xrange = x2 - x1
yrange = y2 - y1
xmesh = xrange / NSX
ymesh = yrange / NSY
tri_height = sqrt(3)/2
ifunc = "vz =MVVal(x,y)"
say ifunc
vz=0
zmax=vz
zmin=vz
call randu(time('s')) /* Seed random number generator */
if typ=3 then call RectCurves
else
if tri then do
if typ=1 then call TriPoints
else call TriMesh
end
else do
if typ=1 then call RectPoints
else call RectMesh
end
l1 = "Points created:" totalpoints
l2 = "Polygons created:" poly
l3 = "Z ranges between" zmin "and" zmax
call notify 1, '!'sysnam, l1, l2, l3
exit
syntax:
error:
call end_all
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit
RectMesh:
totalpoints = (NSX+1) * (NSY+1)
totalpolys = NSX * NSY
call add_begin
call meter_begin totalpoints+2, sysnam, "Computing "totalpoints" points for "totalpolys" squares"
do y=y1 to y2 by ymesh
do x=x1 to x2 by xmesh
interpret ifunc
if vz<zmin then zmin=vz
if vz>zmax then zmax=vz /* Just some silly stats for later */
/* if (flip) then vec =x vz y */
vec = x y vz
call add_point(vec)
call meter_step
end
end
point=1
poly=0
call meter_begin totalpolys, sysnam, "Generating "totalpolys" Polygon Mesh"
do y=y1 to y2-ymesh by ymesh /* Don't make wrap-around polygon */
do x=x1 to x2 by xmesh
if x<x2 then do /* Again, Don't make wrap-around polygon! */
if (flip) then
call add_quad point point+NSX+1 point+NSX+2 point+1
else
call add_quad point point+1 point+NSX+2 point+NSX+1
poly = poly + 1
call meter_step
end
point = point + 1
end
end
call meter_end
call add_end
return totalpoints
/* */
RectPoints:
totalpoints = (NSX+1) * (NSY+1)
poly=totalpoints
call add_begin
call meter_begin totalpoints+2, sysnam, "Computing "totalpoints" points for 1-point polygons"
point=1
do y=y1 to y2 by ymesh
do x=x1 to x2 by xmesh
interpret ifunc
if vz<zmin then zmin=vz
if vz>zmax then zmax=vz /* Just some silly stats for later */
/* if (flip) then vec =x vz y */
vec = x y vz
call add_point(vec)
call add_polygon(point)
point=point+1
call meter_step
end
end
call add_end
return totalpoints
/* */
RectCurves:
totalpoints = (NSX+1) * (NSY+1)
poly=NSX+1 + NSY+1
call add_begin
call meter_begin totalpoints+NSX+2, sysnam, "Computing "totalpoints" points for "poly" Curves"
crv=""
point=1
do y=y1 to y2 by ymesh
do x=x1 to x2 by xmesh
interpret ifunc
if vz<zmin then zmin=vz
if vz>zmax then zmax=vz
/* if (flip) then vec =x vz y */
vec = x y vz
call add_point(vec)
crv=crv point
point=point+1
call meter_step
end
call Add_Curve(crv)
crv=""
end
do p=1 to NSX+1
do o=0 to NSY
crv=crv p+o*(NSX+1)
end
call meter_step
call Add_Curve(crv)
crv=""
end
call add_end
return totalpoints
/* */
TriMesh:
totalpoints = (NSX+1) * (NSY+1)
totalpolys = NSX * NSY * 2
call add_begin
call meter_begin totalpoints*2, sysnam, "Computing "totalpoints" points"
offset=0
rows=0
totalpoints=0
do y=y1 to y2 by ymesh* tri_height
rows=rows+1
columns=0
if y=y2 then TopCorner.4=totalpoints
do x=x1+offset to x2+offset by xmesh
columns = columns + 1
interpret ifunc
if vz<zmin then zmin=vz
if vz>zmax then zmax=vz /* Just some silly stats for later */
/* if (flip) then vec =x vz y */
vec = x y vz
call add_point vec
totalpoints = totalpoints + 1
call meter_step
end
if y=y1 then TopCorner.2=totalpoints
if y=y2 then TopCorner.3=totalpoints
if offset=0 then offset=.5 * xmesh /* offset alternate lines */
else offset=0
end
call meter_end
point=1
poly=0
off=0
call meter_begin totalpolys, sysnam, "Generating "totalpolys" Polygon Mesh"
do row=0 to rows-2
if off=0 then off=1 /* Boy this feels kludgey!!! */
else off=0
do col=1 to columns - 1
if (flip) then do
call add_quad col+row*columns col+(row*columns)+1 col+((row+1)*columns)+abs(off-1)
call add_quad col+(row*columns)+off col+((row+1)*columns)+1 col+((row+1)*columns)
poly=poly+2
end
else do
call add_quad col+row*columns col+((row+1)*columns)+abs(off-1) col+(row*columns)+1
call add_quad col+(row*columns)+off col+((row+1)*columns) col+((row+1)*columns)+1
poly=poly+2
end
call meter_step
end
end
call meter_end
call add_end
return totalpoints
/* */
TriPoints:
totalpoints = (NSX+1) * (NSY+1)
call add_begin
call meter_begin totalpoints*2, sysnam, "Computing "totalpoints" points for 1-point polygons"
offset=0
rows=0
totalpoints=0
point=1
do y=y1 to y2 by ymesh* tri_height
rows=rows+1
columns=0
do x=x1+offset to x2+offset by xmesh
columns = columns + 1
interpret ifunc
if vz<zmin then zmin=vz
if vz>zmax then zmax=vz /* Just some silly stats for later */
/* if (flip) then vec =x vz y */
vec = x y vz
call add_point vec
call add_polygon point
point=point+1
call meter_step
end
if offset=0 then offset=.5 * xmesh /* offset alternate lines */
else offset=0
end
call meter_end
totalpoints = point - 1
poly=totalpoints
call add_end()
return totalpoints
MVVal: Procedure
arg vx,vy
X vx
Y vy
Get Eval "fa" ; z=RESULT
return z
/* */